<?php
	include("access/login_functions.php");
	require("access/connect.php");
	
	$sw[] = $_POST['sw1'];
	$sw[]= $_POST['sw2'];
	$sw[] = $_POST['sw3'];
	$sw[] = $_POST['sw4'];
	$sw[] = $_POST['sw5'];
	$sw[] = $_POST['sw6'];
	$userID = intval($_POST['UID']);
	if(isset($_POST['stopword']))
		$swtodel = $_POST['stopword'];
	
	foreach($sw as $stopword){
		if(!empty($stopword)){
			mysql_query("INSERT INTO stopword_table(Stopword, UID) VALUES('$stopword', $userID)") or die("Stopwords could not be Inserted. ".mysql_error());
		}
	}
	if(isset($swtodel)){
		foreach($swtodel as $sw){
			if(!empty($sw))
				mysql_query("DELETE FROM stopword_table WHERE Stopword ='$sw' AND UID = $userID") or die("Stopwords could not be Deleted. ".mysql_error());
		}
	}
	send_to_page("editstopwords.php");
?>